iconhelper: Move invalidation check
authorBenjamin Otte <otte@redhat.com>
Sun, 29 Nov 2015 00:36:10 +0000 (01:36 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 1 Dec 2015 23:29:29 +0000 (00:29 +0100)
Just do the invalidation check once, there's no need to do it in every
branch of the switch.

Also remove useless checks: These functions will not be called if we
already have a rendered surface.

gtk/gtkiconhelper.c

index 89488c3d634336ebc1ba17363b02cb20d589e542..4f222ad77b0cbc5e374f67a4e78fd8d7fb8c01c0 100644 (file)
@@ -308,9 +308,6 @@ ensure_pixbuf_for_gicon (GtkIconHelper   *self,
   GtkIconInfo *info;
   GtkIconLookupFlags flags;
 
-  if (!check_invalidate_pixbuf (self, context))
-    return;
-
   icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context));
   flags = get_icon_lookup_flags (self, context);
 
@@ -331,9 +328,6 @@ ensure_pixbuf_for_icon_set (GtkIconHelper *self,
                             GtkStyleContext *context,
                             GtkIconSet *icon_set)
 {
-  if (!check_invalidate_pixbuf (self, context))
-    return;
-
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   self->priv->rendered_pixbuf = 
     gtk_icon_set_render_icon_pixbuf (icon_set, context, self->priv->icon_size);
@@ -377,13 +371,6 @@ ensure_pixbuf_from_surface (GtkIconHelper   *self,
   gint width, height;
   cairo_t *cr;
 
-
-  if (!check_invalidate_pixbuf (self, context))
-    return;
-
-  if (self->priv->rendered_pixbuf)
-    return;
-
   get_surface_size (self, orig_surface, &width, &height);
 
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
@@ -409,12 +396,6 @@ ensure_pixbuf_at_size (GtkIconHelper   *self,
   gint width, height;
   GdkPixbuf *stated;
 
-  if (!check_invalidate_pixbuf (self, context))
-    return;
-
-  if (self->priv->rendered_pixbuf)
-    return;
-
   if (self->priv->force_scale_pixbuf &&
       (self->priv->pixel_size != -1 ||
        self->priv->icon_size != GTK_ICON_SIZE_INVALID))
@@ -461,6 +442,9 @@ _gtk_icon_helper_ensure_pixbuf (GtkIconHelper *self,
   GtkIconSet *icon_set;
   GIcon *gicon;
 
+  if (!check_invalidate_pixbuf (self, context))
+    return g_object_ref (self->priv->rendered_pixbuf);
+
   switch (gtk_image_definition_get_storage_type (self->priv->def))
     {
     case GTK_IMAGE_SURFACE: